package com.ytsky.hctechnologysys.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Dell
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    private  static final Logger logger = LoggerFactory.getLogger(EmployeeController.class);
    //这个注解所标注的方法，是某个异常抛出时，被调用的异常方法
    @ExceptionHandler(Exception.class)
    public ModelAndView exceptionHandler(Exception e) {
        ModelAndView  mav = new ModelAndView("common/500");
        e.printStackTrace();
        //将异常信息记录到日志中
        logger.error(e.getMessage(),e);

        return mav;
    }
}
